package com.hry.store.cms.service.impl;

import com.hry.store.cms.dao.ProductColorMapper;
import com.hry.store.cms.pojo.ProductColor;
import com.hry.store.cms.service.ColorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ColorServiceImpl implements ColorService {
    @Autowired
    private ProductColorMapper colorMapper;

    /**
     * 查询颜色分类
     * @param secondCategoryId
     * @param versionId
     * @return
     */
    @Override
    public List<ProductColor> getBySecondCategoryId(Integer secondCategoryId, Integer versionId) {
        return colorMapper.getBySecondCategoryId(secondCategoryId, versionId);
    }

    /**
     * 添加颜色分类
     * @param secondCategoryId
     * @param versionId
     * @param colorCode
     * @param colorName
     * @return
     */
    @Override

    public int addColor(Integer secondCategoryId, Integer versionId, String colorCode, String colorName, String urls, Integer quantity) {
        ProductColor color = new ProductColor();
        color.setColorCode(colorCode);
        color.setColorName(colorName);
        color.setSecondCategoryId(secondCategoryId);
        color.setVersionId(versionId);
        color.setProductImgs(urls);
        color.setQuantity(quantity);
        return colorMapper.insertSelective(color);
    }
}
